<?php

namespace Module\RightClickForbidden\Core;

use Illuminate\Events\Dispatcher;
use Illuminate\Support\Facades\View;
use Illuminate\Support\ServiceProvider;
use ModStart\Admin\Config\AdminMenu;
use ModStart\Core\Hook\ModStartHook;

class ModuleServiceProvider extends ServiceProvider
{
    /**
     * Bootstrap any application services.
     *
     * @return void
     */
    public function boot(Dispatcher $events)
    {
        ModStartHook::subscribe('PageHeadAppend', function () {
            if (modstart_config('RightClickForbidden_Enable', false)) {
                return View::make('module::RightClickForbidden.View.widget.code');
            }
        });
        ModStartHook::subscribe('DialogPageHeadAppend', function () {

            if (modstart_config('RightClickForbidden_Enable', false)) {
                return View::make('module::RightClickForbidden.View.widget.code');
            }
        });
        AdminMenu::register(function () {
            return [
                [
                    'title' => '功能设置',
                    'icon' => 'tools',
                    'sort' => 300,
                    'children' => [
                        [
                            'title' => '鼠标禁止右击',
                            'url' => '\Module\RightClickForbidden\Admin\Controller\ConfigController@setting',
                        ]
                    ]
                ]
            ];
        });
    }

    /**
     * Register any application services.
     *
     * @return void
     */
    public function register()
    {

    }
}
